plotHawkCoefs2 = function(append="") {

  meanFits = paste0("meanFit1", c("a", "b", "c", "d"), append)
  leaderFits = paste0("leaderFit1", c("a", "b", "c", "d"), append)
  compFits = paste0("compFit1", c("a", "b", "c", "d"), append)
  
  allFits = c(meanFits, leaderFits, compFits)
  
  mCoefs = mSEs = NA
  for (i in 1:length(allFits)) {
    
    theFit = get(allFits[i])[["results"]]
    
    if (grepl("meanFit|leaderFit", allFits[i])) {
      hawkInd = grepl("Hawkishness", theFit[["term"]])
      mCoefs[i] = theFit[hawkInd, "est_mean"]
      mSEs[i] = theFit[hawkInd, "se_mean"]
    } else {
      advInd = grepl("Adviser", theFit$term)
      mCoefs[i] = theFit[advInd,"est_mean"]
      mSEs[i] = theFit[advInd,"se_mean"]
    }
    

  }

  figData = data.frame(coefs = unlist(mCoefs), se = unlist(mSEs))
  
  figData$low = figData$coefs - 1.96*figData$se
  figData$low10 = figData$coefs - 1.69*figData$se
  figData$high = figData$coefs + 1.96*figData$se
  figData$high10 = figData$coefs + 1.69*figData$se
  
  figData$Model = c("Sparse", "With controls")
  figData$Mechanism = rep(c("Emergence Model\n(Coefficient for Group Mean)", 
                            "Leader Model\n(Coefficient for President)", 
                            "Adviser Model\n(Coefficient for Advisers)"), each=4)
  figData$Mechanism = factor(figData$Mechanism,
                             levels=c("Emergence Model\n(Coefficient for Group Mean)", 
                             "Leader Model\n(Coefficient for President)", 
                             "Adviser Model\n(Coefficient for Advisers)"))
  
  figData$Label = rep(c("Conf.\n(Poisson)\nSparse", "Conf.\n(Poisson)\nFull", "Conf.-Coop.\n(OLS)\nSparse", "Conf.-Coop.\n(OLS)\nFull"), 3)
  figData$Label = factor(figData$Label, levels=c("Conf.\n(Poisson)\nSparse", "Conf.\n(Poisson)\nFull", "Conf.-Coop.\n(OLS)\nSparse", "Conf.-Coop.\n(OLS)\nFull"))
  
  figData$signif = ifelse((figData$coefs > 0 & figData$low > 0) | (figData$coefs < 0 & figData$high < 0), "Yes", "No")
  
  figSave = ggplot(figData, aes(x=Label, y=coefs)) + 
    geom_pointrange(aes(ymin=low, ymax=high, color=Label, shape=signif)) + 
    geom_linerange(aes(ymin=low10, ymax=high10, color=Label), size=1.5) + 
    geom_hline(yintercept=0, linetype=2) + theme_bw() + ylab("Coefficient Estimate") + 
    xlab("Model") + 
    scale_color_manual("Model", values=c("tomato", "red3", "dodgerblue", "royalblue3")) + 
    facet_grid(cols=vars(Mechanism)) +
    theme(legend.position="none", axis.text.x = element_text(angle=90, vjust=0.5)) +
    scale_shape_manual(values=c(16,15))
  
  figSave
}


plotMainHawkCoefs2 = function(append="") {
  
  meanFits = paste0("meanFit1", c("b", "d"), append)
  leaderFits = paste0("leaderFit1", c("b", "d"), append)
  compFits = paste0("compFit1", c("b", "d"), append)
  
  allFits = c(meanFits, leaderFits, compFits)
  
  mCoefs = mSEs = NA
  for (i in 1:length(allFits)) {
    
    theFit = get(allFits[i])[["results"]]
    
    if (grepl("meanFit|leaderFit", allFits[i])) {
      hawkInd = grepl("Hawkishness", theFit[["term"]])
      mCoefs[i] = theFit[hawkInd, "est_mean"]
      mSEs[i] = theFit[hawkInd, "se_mean"]
    } else {
      advInd = grepl("Adviser", theFit$term)
      mCoefs[i] = theFit[advInd,"est_mean"]
      mSEs[i] = theFit[advInd,"se_mean"]
    }
    
    
  }
  
  figData = data.frame(coefs = unlist(mCoefs), se = unlist(mSEs))
  
  figData$low = figData$coefs - 1.96*figData$se
  figData$low10 = figData$coefs - 1.69*figData$se
  figData$high = figData$coefs + 1.96*figData$se
  figData$high10 = figData$coefs + 1.69*figData$se
  
  figData$Model = c("Sparse", "With controls")
  figData$Mechanism = rep(c("Emergence Model\n(Coefficient for Group Mean)", 
                            "Leader Model\n(Coefficient for President)", 
                            "Adviser Model\n(Coefficient for Advisers)"), each=2)
  figData$Mechanism = factor(figData$Mechanism,
                             levels=c("Emergence Model\n(Coefficient for Group Mean)", 
                                      "Leader Model\n(Coefficient for President)", 
                                      "Adviser Model\n(Coefficient for Advisers)"))
  
  figData$Label = rep(c("Conf.\n(Poisson)", "Conf.-Coop.\n(OLS)"), 3)
  figData$Label = factor(figData$Label, levels=c("Conf.\n(Poisson)", "Conf.-Coop.\n(OLS)"))
  
  figData$signif = ifelse((figData$coefs > 0 & figData$low > 0) | (figData$coefs < 0 & figData$high < 0), "Yes", "No")
  
  figSave = ggplot(figData, aes(x=Label, y=coefs)) + 
    geom_pointrange(aes(ymin=low, ymax=high, color=Label, shape=signif)) + 
    geom_linerange(aes(ymin=low10, ymax=high10, color=Label), size=1.5) + 
    geom_hline(yintercept=0, linetype=2) + theme_bw() + ylab("Coefficient Estimate") + 
    xlab("Model") + 
    scale_color_manual("Model", values=c("red3", "royalblue3")) + 
    facet_grid(cols=vars(Mechanism)) +
    theme(legend.position="none", axis.text.x = element_text(angle=90, vjust=0.5)) +
    scale_shape_manual(values=c(16,15))
  
  figSave
}
